package org.ghost.http.testkit.controller;

import org.ghost.http.testkit.dto.ResponseVO;
import org.ghost.http.testkit.util.ResponseUtil;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public abstract class BaseController {

    @Resource
    protected HttpServletRequest request;

    @Resource
    protected HttpServletResponse response;

    protected ResponseVO getSuccess() {
        return ResponseUtil.getSuccess();
    }

    protected ResponseVO getFromData(Object data) {
        ResponseVO responseVO = getSuccess();
        responseVO.setData(data);
        return responseVO;
    }

    protected ResponseVO getFailure() {
        return ResponseUtil.getFailure();
    }

    protected ResponseVO getResponse(Object data) {
        ResponseVO responseVO = getSuccess();
        responseVO.setData(data);
        return responseVO;
    }
}
